package com.android.fastride.view.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.fastride.R;
import com.android.fastride.contract.RatingListContract;
import com.android.fastride.model.db.entity.Rating;
import com.android.fastride.present.RatingListPresent;
import com.android.fastride.view.widget.TopBar;
import com.chad.library.adapter.base.BaseViewHolder;
import com.iarcuschin.simpleratingbar.SimpleRatingBar;
import com.peng.library.mantis.expand.list.MantisListFragment;
import com.peng.library.mantis.expand.list.link.ListConfig;
import com.peng.library.mantis.expand.refresh.link.RefreshConfig;
import com.peng.library.mantis.hint.HintConfig;
import com.peng.library.mantis.mvp.BindPresent;
import com.peng.library.mantis.mvp.IViewDelegate;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

@BindPresent(RatingListPresent.class)
public class RatingListFragment extends MantisListFragment<RatingListContract.PRESENT, Rating>
        implements
        RatingListContract.VIEW {

    View view;
    Unbinder unbinder;
    @BindView(R.id.topbar)
    TopBar topbar;
    @BindView(R.id.tv_grade)
    TextView tvGrade;
    @BindView(R.id.rb_distribution)
    SimpleRatingBar rbDistribution;
    @BindView(R.id.tv_distribution_grade)
    TextView tvDistributionGrade;
    @BindView(R.id.rb_serve)
    SimpleRatingBar rbServe;
    @BindView(R.id.tv_serve_grade)
    TextView tvServeGrade;
    @BindView(R.id.rb_commodity)
    SimpleRatingBar rbCommodity;
    @BindView(R.id.tv_commodity_grade)
    TextView tvCommodityGrade;
    @BindView(R.id.rv_comment_list)
    RecyclerView rvCommentList;
    @BindView(R.id.tv_total_comment)
    TextView tvTotalComment;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable
            Bundle savedInstanceState, HintConfig.Builder hintConfigBuilder, RefreshConfig
            .Builder refreshConfigBuilder, ListConfig.Builder listConfigBuilder) {
        view = inflater.inflate(R.layout.fragment_my_rating, container, false);
        unbinder = ButterKnife.bind(this, view);
        hintConfigBuilder.layoutEmptyId(R.layout.hint_empty);
        refreshConfigBuilder.needRefreshViewId(R.id.rv_comment_list);
        refreshConfigBuilder.refreshEnable(false);
        refreshConfigBuilder.autoRefresh(false);
        listConfigBuilder.recyclerViewId(R.id.rv_comment_list);
        listConfigBuilder.hasDivider(false);
        topbar.setOnLeftAndRightClickListener(new TopBar.OnLeftAndRightClickListener() {
            @Override
            public void OnLeftButtonClick() {
                getActivity().finish();
            }

            @Override
            public void OnRightButtonClick() {

            }
        });
        return view;
    }

    @Override
    public void onConvert(BaseViewHolder holder, Rating rating, int position) {

    }

    @Override
    public void onReceiveError(Throwable error) {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (unbinder != null) {
            unbinder.unbind();
        }
    }

    @OnClick(R.id.iv_all_comment)
    public void onClick() {
    }

    @Override
    public void autoRefresh() {

    }

    @Override
    public void refreshComplete() {

    }

    @Override
    public boolean isRefreshing() {
        return false;
    }

    @Override
    public RatingListContract.PRESENT getPresent() {
        return super.getPresent();
    }

    @Override
    public IViewDelegate getViewDelegate() {
        return null;
    }

    @Override
    public void onRefreshCall() {

    }

    @Override
    public int getItemLayout() {
        return R.layout.list_item_my_rating;
    }
}
